#!/bin/bash

data_file=`date  +"%Y-%m-%d-%H%M%S"`

remote_ip="119.97.251.134"
remote_user="518cyj"
remote_pass_file="/etc/rsyncd.secrets"
remote_dir_name="118_178_133_29_backup"

local_src=/vdb1/518_anhui/app/roadshowcenter_app/wwwroot/upload
remote_dst=/vdb1/518_anhui/app/roadshowcenter_app/


echo "$remote_user@$remote_ip::$remote_dir_name$remote_dst"
/usr/bin/inotifywait  -mrq --timefmt '%d/%m/%y/%H:%M' --format '%T%w%f' -e modify,delete,create,attrib $local_src | while read file
       do
       rsync -vzrtopg --delete --progress $local_src $remote_user@$remote_ip::$remote_dir_name$remote_dst  --password-file=/etc/rsyncd.secrets &&
       echo "$local_src has been resynced"
       done
